<?php
// Let the user define LIBPATH, if they want
if(!defined("LIBPATH"))
	define("LIBPATH", $_SERVER['DOCUMENT_ROOT'] . "lib" . DIRECTORY_SEPARATOR);

/*!
	\file func.autoloader.php
	\brief Contains the __autoload PHP 5 function definition
	\author Alex McClung
	\date Created:  October 21, 2007
	\date Modified: November 29, 2007
	
	Standard __autoload function. It will recursively search the library subdirectories (defined by LIBPATH).
*/
function __autoload($class_name)
{
	// Does the class already exist?
	if(class_exists($class_name))
		return;
		
	// Start at the base library path
	$path = LIBPATH;

	// Array of subdirectories in the library path to search through.
	// This is hard-coded for SPEED.
	$subdirs = array(".", "SimpleDBO", "SimpleDBO/DBO/", "calendar", "image", "mail", "passwordgen");
	
	foreach($subdirs as $subdir)
	{
		$fullpath = $path . "$subdir" . DIRECTORY_SEPARATOR . "class.{$class_name}.php";
		
		if(file_exists($fullpath) && ! class_exists($class_name))
		{
			require_once($fullpath);
			return;
		}
	}
}

// Auto-preloads (because they're important and used EVERYWHERE)
__autoload('SimpleDBO');
__autoload('SuperConstructor');
?>